package lex;

import java.util.List;

public class Dump
{
	private List<Token> matches;
	
	public Dump(List<Token> matches)
	{
		this.matches = matches;
	}
	
	public String console()
	{
		StringBuilder sb1 = new StringBuilder();

		sb1.append(String.format("%-12s %-12s %-4s : %-5s\n", "token", "tag", "line", "column"));

		for (Token m : matches) {
			if(m.tag.compareTo("ERROR") == 0) {
				sb1.append(String.format("%d:%d : %s\n", m.line, m.column, m.value));
				break;
			}

			sb1.append(String.format("%-12s %-12s %2d      %2d\n", m.value, m.tag, m.line, m.column));
		}

		return sb1.toString();
	}
}
